<?php

/**
 * Submits notification messages to the mobile clients.
 *
 * @author Michael Mitteregger <Michael.Mitteregger.ITM09@fh-joanneum.at>
 */

require_once 'lib.php';
require_once 'lib\SubmitNotificationHelper.php';

// If the key is sent via POST, use POST instead of GET.
if(isset($_POST['k'])){
    $_GET = $_POST;
}

$mType = $_GET['type'];
// Additional info can be empty
$mAddInfo = '';
if(isset($_GET['additionalinfo'])){
    $mAddInfo = $_GET['additionalinfo'];
}
$key = $_GET['k'];

// Create helper, and do the work.
$h = new SubmitNotificationHelper($key, $mType, $mAddInfo);
$h->perform();

// Prepare the output
$output = '<?xml version="1.0"?>';
$output .= '<SubmitNotification>';
$output .= '<Status>'.$h->status.'</Status>';
$output .= '<Type>'.$mType.'</Type>';
$output .= '<AdditionalInfo>'.$mAddInfo.'</AdditionalInfo>';
$output .= "</SubmitNotification>";

header ("Content-Type:text/xml");
echo $output;
exit();

?>